import Vue from 'vue'
import Router from 'vue-router'
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
/** 公共*/
import Layout from '../views/layout/Layout'
import financialflow from './modules/after-sale/financialflow' // 财务流水
import personnel from './modules/after-sale/personnel' // 人事管理
import systemManage from './modules/after-sale/systemManage' // 系统管理
import clientManage from './modules/after-sale/client-manage'
import customerCenter from './modules/after-sale/customer-center'// 客服中心
import recordsCenter from './modules/after-sale/recordsCenter' // 数据中心
/** 售后*/
import storehouseManage from './modules/after-sale/storehouseManage' // 库房管理
import workOrderManage from './modules/after-sale/workOrderManage' // 工单管理
import partsStockManage from './modules/after-sale/partsStockManage' // 采购管理

/** 售前*/
import advertManagement from './modules/pre-sale/advertManagement' // 广告管理
import orderManagement from './modules/pre-sale/orderManagement' // 订单管理
import intentionalCustomer from './modules/pre-sale/intentionalCustomer'
import supplierManage from './modules/pre-sale/supplierManage' // 供应商管理
import qualityManagement from './modules/pre-sale/qualityManagement' // 精品管理
import taskCenter from './modules/pre-sale/taskCenter' // 任务中心
import boutiqueStock from './modules/pre-sale/boutiqueStock' // 精品库房管理
import newCarStock from './modules/pre-sale/newCarStock' // 新车库存
import boutiquePurchase from './modules/pre-sale/boutiquePurchase' // 采购管理
import permissionManagement from './modules/pre-sale/permissionManagement' // 采购管理


/** note: submenu only apppear when children.length>=1
 *   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/changePassword',
    component: () => import('@/views/login/password'),
    hidden: true
  },
  {
    path: '/authredirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },

]

export const asyncRouterMap = [
  {
    path: '/',
    component: Layout,
    name: '/',
    alwaysShow: true,
    hidden: true,
    redirect: '/dashboard',
    meta: {
      title: 'dashboard',
      icon: 'activity'
    },
    children: [
      {
        path: '/dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'dashboard',
        alwaysShow: true,
        meta: {
          title: 'dashboard',
          affix: true
        }
      }
    ]
  },
  customerCenter,
  clientManage,
  workOrderManage,
  storehouseManage,
  partsStockManage,
  financialflow,
  personnel,
  systemManage,
  recordsCenter,
  advertManagement,
  orderManagement,
  intentionalCustomer,
  supplierManage,
  qualityManagement,
  taskCenter,
  newCarStock,
  boutiquePurchase,
  boutiqueStock,
  permissionManagement,
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
  // {
  //   path: '/iconTest',
  //   component: Layout,
  //   name: 'iconTest',
  //   alwaysShow: true,
  //   meta: {
  //     title: 'iconTest',
  //     icon: 'activity'
  //   },
  //   children: [
  //     {
  //       path: 'iconTest2', // 图标测试页面
  //       component: () => import('@/views/test/index.vue'),
  //       name: 'iconTest2',
  //       meta: {
  //         title: 'iconTest2'
  //       }
  //     }
  //   ]
  // },
]
export default new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap,
})
